home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / lisp / mh-e / mh-comp.el.z / mh-comp.el
Encoding:
Text File  |  1998-05-21  |  39.7 KB  |  1,100 lines

  1. ;;; mh-comp --- mh-e functions for composing messages
  2. ;; Time-stamp: <95/08/19 17:48:59 gildea>
  3.  
  4. ;; Copyright (C) 1993, 1995 Free Software Foundation, Inc.
  5.  
  6. ;; This file is part of mh-e, part of GNU Emacs.
  7.  
  8. ;; GNU Emacs is free software; you can redistribute it and/or modify
  9. ;; it under the terms of the GNU General Public License as published by
  10. ;; the Free Software Foundation; either version 2, or (at your option)
  11. ;; any later version.
  12.  
  13. ;; GNU Emacs is distributed in the hope that it will be useful,
  14. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. ;; GNU General Public License for more details.
  17.  
  18. ;; You should have received a copy of the GNU General Public License
  19. ;; along with GNU Emacs; see the file COPYING.  If not, write to
  20. ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22. ;;; Commentary:
  23.  
  24. ;; Internal support for mh-e package.
  25.  
  26. ;;; Change Log:
  27.  
  28. ;; $Id: mh-comp.el,v 1.10 95/09/23 18:06:19 gildea Exp $
  29.  
  30. ;;; Code:
  31.  
  32. (provide 'mh-comp)
  33. (require 'mh-utils)
  34.  
  35. ;;; Site customization (see also mh-utils.el):
  36.  
  37. (defgroup mh-compose nil
  38.   "Mh-e functions for composing messages"
  39.   :prefix "mh-"
  40.   :group 'mh)
  41.  
  42.  
  43. (defvar mh-send-prog "send"
  44.   "Name of the MH send program.
  45. Some sites need to change this because of a name conflict.")
  46.  
  47. (defvar mh-redist-full-contents nil
  48.   "Non-nil if the `dist' command needs whole letter for redistribution.
  49. This is the case only when `send' is compiled with the BERK option.
  50. If MH will not allow you to redist a previously redist'd msg, set to nil.")
  51.  
  52.  
  53. (defvar mh-note-repl "-"
  54.   "String whose first character is used to notate replied to messages.")
  55.  
  56. (defvar mh-note-forw "F"
  57.   "String whose first character is used to notate forwarded messages.")
  58.  
  59. (defvar mh-note-dist "R"
  60.   "String whose first character is used to notate redistributed messages.")
  61.  
  62. (defvar mh-yank-hooks nil
  63.   "Obsolete hook for modifying a citation just inserted in the mail buffer.
  64. Each hook function can find the citation between point and mark.
  65. And each hook function should leave point and mark around the citation
  66. text as modified.
  67.  
  68. This is a normal hook, misnamed for historical reasons.
  69. It is semi-obsolete and is only used if mail-citation-hook is nil.")
  70.  
  71. (defvar mail-citation-hook nil
  72.   "*Hook for modifying a citation just inserted in the mail buffer.
  73. Each hook function can find the citation between point and mark.
  74. And each hook function should leave point and mark around the citation
  75. text as modified.
  76.  
  77. If this hook is entirely empty (nil), the text of the message is inserted
  78. with mh-ins-buf-prefix prefixed to each line.
  79.  
  80. See also the variable mh-yank-from-start-of-msg, which controls how
  81. much of the message passed to the hook.")
  82.  
  83. ;;; Copied from sendmail.el for Hyperbole
  84. (defvar mail-header-separator "--------"
  85.   "*Line used by MH to separate headers from text in messages being composed.")
  86.  
  87. ;;; Personal preferences:
  88.  
  89. (defcustom mh-delete-yanked-msg-window nil
  90.   "*Controls window display when a message is yanked by \\<mh-letter-mode-map>\\[mh-yank-cur-msg].
  91. If non-nil, yanking the current message into a draft letter deletes any
  92. windows displaying the message."
  93.   :type 'boolean
  94.   :group 'mh-compose)
  95.  
  96. (defcustom mh-yank-from-start-of-msg t
  97.   "*Controls which part of a message is yanked by \\<mh-letter-mode-map>\\[mh-yank-cur-msg].
  98. If non-nil, include the entire message.  If the symbol `body', then yank the
  99. message minus the header.  If nil, yank only the portion of the message
  100. following the point.  If the show buffer has a region, this variable is
  101. ignored."
  102.   :type '(choice (const t) (const nil) (const body))
  103.   :group 'mh-compose)
  104.  
  105. (defcustom mh-ins-buf-prefix "> "
  106.   "*String to put before each non-blank line of a yanked or inserted message.
  107. \\<mh-letter-mode-map>Used when the message is inserted into an outgoing letter
  108. by \\[mh-insert-letter] or \\[mh-yank-cur-msg]."
  109.   :type 'string
  110.   :group 'mh-compose)
  111.  
  112. (defcustom mh-reply-default-reply-to nil
  113.   "*Sets the person or persons to whom a reply will be sent.
  114. If nil, prompt for recipient.  If non-nil, then \\<mh-folder-mode-map>`\\[mh-reply]' will use this
  115. value and it should be one of \"from\", \"to\", \"cc\", or \"all\".
  116. The values \"cc\" and \"all\" do the same thing."
  117.   :type '(choice (const :tag "Prompt" nil)
  118.          (const "from") (const "to")
  119.          (const "cc") (const "all"))
  120.   :group 'mh-compose)
  121.  
  122. (defcustom mh-signature-file-name "~/.signature"
  123.   "*Name of file containing the user's signature.
  124. Inserted into message by \\<mh-letter-mode-map>\\[mh-insert-signature]."
  125.   :type 'file
  126.   :group 'mh-compose)
  127.  
  128. (defcustom mh-forward-subject-format "%s: %s"
  129.   "*Format to generate the Subject: line contents for a forwarded message.
  130. The two string arguments to the format are the sender of the original
  131. message and the original subject line."
  132.   :type 'string
  133.   :group 'mh-compose)
  134.  
  135. (defvar mh-comp-formfile "components"
  136.   "Name of file to be used as a skeleton for composing messages.
  137. Default is \"components\".  If not a complete path name, the file
  138. is searched for first in the user's MH directory, then in the
  139. system MH lib directory.")
  140.  
  141. (defvar mh-repl-formfile "replcomps"
  142.   "Name of file to be used as a skeleton for replying to messages.
  143. Default is \"replcomps\".  If not a complete path name, the file
  144. is searched for first in the user's MH directory, then in the
  145. system MH lib directory.")
  146.  
  147. ;;; Hooks:
  148.  
  149. (defcustom mh-letter-mode-hook nil
  150.   "Invoked in `mh-letter-mode' on a new letter."
  151.   :type 'hook
  152.   :group 'mh-compose)
  153.  
  154. (defcustom mh-compose-letter-function nil
  155.   "Invoked when setting up a letter draft.
  156. It is passed three arguments: TO recipients, SUBJECT, and CC recipients."
  157.   :type 'function
  158.   :group 'mh-compose)
  159.  
  160. (defcustom mh-before-send-letter-hook nil
  161.   "Invoked at the beginning of the \\<mh-letter-mode-map>\\[mh-send-letter] command."
  162.   :type 'hook
  163.   :group 'mh-compose)
  164.  
  165.  
  166. (defvar mh-rejected-letter-start
  167.   (concat "^   ----- Unsent message follows -----$"    ;from sendmail V5
  168.       "\\|^   ----- Original message follows -----$" ;from sendmail V8
  169.       "\\|^------- Unsent Draft$"            ;from MH itself
  170.       "\\|^----------  Original Message  ----------$" ;from zmailer
  171.       "\\|^  --- The unsent message follows ---$"    ;from AIX mail system
  172.       "\\|^    Your message follows:$"        ;from MMDF-II
  173.       "\\|^Content-Description: Returned Content$"    ;1993 KJ sendmail
  174.       )
  175.   "Regexp specifying the beginning of the wrapper around a returned letter.
  176. This wrapper is generated by the mail system when rejecting a letter.")
  177.  
  178. (defvar mh-new-draft-cleaned-headers
  179.   "^Date:\\|^Received:\\|^Message-Id:\\|^From:\\|^Sender:\\|^Errors-To:\\|^Delivery-Date:\\|^Return-Path:"
  180.   "Regexp of header lines to remove before offering a message as a new draft.
  181. Used by the \\<mh-folder-mode-map>`\\[mh-edit-again]' and `\\[mh-extract-rejected-mail]' commands.")
  182.  
  183. (defvar mh-to-field-choices '(("t" . "To:") ("s" . "Subject:") ("c" . "Cc:")
  184.                   ("b" . "Bcc:") ("f" . "Fcc:") ("r" . "From:")
  185.                   ("d" . "Dcc:"))
  186.   "Alist of (final-character . field-name) choices for mh-to-field.")
  187.  
  188. (defvar mh-letter-mode-map (copy-keymap text-mode-map)
  189.   "Keymap for composing mail.")
  190.  
  191. (defvar mh-letter-mode-syntax-table nil
  192.   "Syntax table used by mh-e while in MH-Letter mode.")
  193.  
  194. (if mh-letter-mode-syntax-table
  195.     ()
  196.     (setq mh-letter-mode-syntax-table
  197.       (make-syntax-table text-mode-syntax-table))
  198.     (modify-syntax-entry ?% "." mh-letter-mode-syntax-table))
  199.  
  200.  
  201. ;;;###autoload
  202. (defun mh-smail ()
  203.   "Compose and send mail with the MH mail system.
  204. This function is an entry point to mh-e, the Emacs front end
  205. to the MH mail system.
  206.  
  207. See documentation of `\\[mh-send]' for more details on composing mail."
  208.   (interactive)
  209.   (mh-find-path)
  210.   (call-interactively 'mh-send))
  211.  
  212.  
  213. (defvar mh-error-if-no-draft nil)    ;raise error over using old draft
  214.  
  215.  
  216. ;;;###autoload
  217. (defun mh-smail-batch ()
  218.   "Set up a mail composition draft with the MH mail system.
  219. This function is an entry point to mh-e, the Emacs front end
  220. to the MH mail system.  This function does not prompt the user
  221. for any header fields, and thus is suitable for use by programs
  222. that want to create a mail buffer.
  223. Users should use `\\[mh-smail]' to compose mail."
  224.   (mh-find-path)
  225.   (let ((mh-error-if-no-draft t))
  226.     (mh-send "" "" "")))
  227.  
  228. ;;;###autoload
  229. (defun mh-user-agent-compose (&optional to subject other-headers continue
  230.                                              switch-function yank-action
  231.                                              send-actions)
  232.   "Set up mail composition draft with the MH mail system.
  233. This is `mail-user-agent' entry point to mh-e.
  234.  
  235. The optional arguments TO and SUBJECT specify recipients and the
  236. initial Subject field, respectively.
  237.  
  238. OTHER-HEADERS is an alist specifying additional
  239. header fields.  Elements look like (HEADER . VALUE) where both
  240. HEADER and VALUE are strings.
  241.  
  242. CONTINUE, SWITCH-FUNCTION, YANK-ACTION and SEND-ACTIONS are ignored."
  243.   (mh-find-path)
  244.   (let ((mh-error-if-no-draft t))
  245.     (mh-send to "" subject)
  246.     (while other-headers
  247.       (mh-insert-fields (concat (car (car other-headers)) ":") 
  248.                        (cdr (car other-headers)))
  249.       (setq other-headers (cdr other-headers)))))
  250.  
  251. (defun mh-edit-again (msg)
  252.   "Clean-up a draft or a message previously sent and make it resendable.
  253. Default is the current message.
  254. The variable mh-new-draft-cleaned-headers specifies the headers to remove.
  255. See also documentation for `\\[mh-send]' function."
  256.   (interactive (list (mh-get-msg-num t)))
  257.   (let* ((from-folder mh-current-folder)
  258.      (config (current-window-configuration))
  259.      (draft
  260.       (cond ((and mh-draft-folder (equal from-folder mh-draft-folder))
  261.          (pop-to-buffer (find-file-noselect (mh-msg-filename msg)) t)
  262.          (rename-buffer (format "draft-%d" msg))
  263.          (buffer-name))
  264.         (t
  265.          (mh-read-draft "clean-up" (mh-msg-filename msg) nil)))))
  266.     (mh-clean-msg-header (point-min) mh-new-draft-cleaned-headers nil)
  267.     (goto-char (point-min))
  268.     (save-buffer)
  269.     (mh-compose-and-send-mail draft "" from-folder nil nil nil nil nil nil
  270.                   config)))
  271.  
  272.  
  273. (defun mh-extract-rejected-mail (msg)
  274.   "Extract a letter returned by the mail system and make it resendable.
  275. Default is the current message.  The variable mh-new-draft-cleaned-headers
  276. gives the headers to clean out of the original message.
  277. See also documentation for `\\[mh-send]' function."
  278.   (interactive (list (mh-get-msg-num t)))
  279.   (let ((from-folder mh-current-folder)
  280.     (config (current-window-configuration))
  281.     (draft (mh-read-draft "extraction" (mh-msg-filename msg) nil)))
  282.     (goto-char (point-min))
  283.     (cond ((re-search-forward mh-rejected-letter-start nil t)
  284.        (skip-chars-forward " \t\n")
  285.        (delete-region (point-min) (point))
  286.        (mh-clean-msg-header (point-min) mh-new-draft-cleaned-headers nil))
  287.       (t
  288.        (message "Does not appear to be a rejected letter.")))
  289.     (goto-char (point-min))
  290.     (save-buffer)
  291.     (mh-compose-and-send-mail draft "" from-folder msg
  292.                   (mh-get-header-field "To:")
  293.                   (mh-get-header-field "From:")
  294.                   (mh-get-header-field "Cc:")
  295.                   nil nil config)))
  296.  
  297.  
  298. (defun mh-forward (to cc &optional msg-or-seq)
  299.   "Forward a message or message sequence.  Defaults to displayed message.
  300. If optional prefix argument provided, then prompt for the message sequence.
  301. See also documentation for `\\[mh-send]' function."
  302.   (interactive (list (mh-read-address "To: ")
  303.              (mh-read-address "Cc: ")
  304.              (if current-prefix-arg
  305.              (mh-read-seq-default "Forward" t)
  306.                (mh-get-msg-num t))))
  307.   (or msg-or-seq
  308.       (setq msg-or-seq (mh-get-msg-num t)))
  309.   (let* ((folder mh-current-folder)
  310.      (config (current-window-configuration))
  311.      ;; forw always leaves file in "draft" since it doesn't have -draft
  312.      (draft-name (expand-file-name "draft" mh-user-path))
  313.      (draft (cond ((or (not (file-exists-p draft-name))
  314.                (y-or-n-p "The file 'draft' exists.  Discard it? "))
  315.                (mh-exec-cmd "forw" "-build"
  316.                     mh-current-folder msg-or-seq)
  317.                (prog1
  318.                (mh-read-draft "" draft-name t)
  319.              (mh-insert-fields "To:" to "Cc:" cc)
  320.              (save-buffer)))
  321.               (t
  322.                (mh-read-draft "" draft-name nil)))))
  323.     (let (orig-from
  324.       orig-subject)
  325.       (goto-char (point-min))
  326.       (re-search-forward "^------- Forwarded Message")
  327.       (forward-line 1)
  328.       (skip-chars-forward " \t\n")
  329.       (save-restriction
  330.     (narrow-to-region (point) (point-max))
  331.     (setq orig-from (mh-get-header-field "From:"))
  332.     (setq orig-subject (mh-get-header-field "Subject:")))
  333.       (let ((forw-subject
  334.          (mh-forwarded-letter-subject orig-from orig-subject)))
  335.     (mh-insert-fields "Subject:" forw-subject)
  336.     (goto-char (point-min))
  337.     (re-search-forward "^------- Forwarded Message")
  338.     (forward-line -1)
  339.     (delete-other-windows)
  340.     (if (numberp msg-or-seq)
  341.         (mh-add-msgs-to-seq msg-or-seq 'forwarded t)
  342.       (mh-add-msgs-to-seq (mh-seq-to-msgs msg-or-seq) 'forwarded t))
  343.     (mh-compose-and-send-mail draft "" folder msg-or-seq
  344.                   to forw-subject cc
  345.                   mh-note-forw "Forwarded:"
  346.                   config)))))
  347.  
  348. (defun mh-forwarded-letter-subject (from subject)
  349.   ;; Return a Subject suitable for a forwarded message.
  350.   ;; Original message has headers FROM and SUBJECT.
  351.   (let ((addr-start (string-match "<" from))
  352.     (comment (string-match "(" from)))
  353.     (cond ((and addr-start (> addr-start 0))
  354.        ;; Full Name <luser@host>
  355.        (setq from (substring from 0 (1- addr-start))))
  356.       (comment
  357.        ;; luser@host (Full Name)
  358.        (setq from (substring from (1+ comment) (1- (length from)))))))
  359.   (format mh-forward-subject-format from subject))
  360.  
  361.  
  362. ;;;###autoload
  363. (defun mh-smail-other-window ()
  364.   "Compose and send mail in other window with the MH mail system.
  365. This function is an entry point to mh-e, the Emacs front end
  366. to the MH mail system.
  367.  
  368. See documentation of `\\[mh-send]' for more details on composing mail."
  369.   (interactive)
  370.   (mh-find-path)
  371.   (call-interactively 'mh-send-other-window))
  372.  
  373.  
  374. (defun mh-redistribute (to cc &optional msg)
  375.   "Redistribute a letter.
  376. Depending on how your copy of MH was compiled, you may need to change the
  377. setting of the variable mh-redist-full-contents.  See its documentation."
  378.   (interactive (list (mh-read-address "Redist-To: ")
  379.              (mh-read-address "Redist-Cc: ")
  380.              (mh-get-msg-num t)))
  381.   (or msg
  382.       (setq msg (mh-get-msg-num t)))
  383.   (save-window-excursion
  384.     (let ((folder mh-current-folder)
  385.       (draft (mh-read-draft "redistribution"
  386.                 (if mh-redist-full-contents
  387.                     (mh-msg-filename msg)
  388.                   nil)
  389.                 nil)))
  390.       (mh-goto-header-end 0)
  391.       (insert "Resent-To: " to "\n")
  392.       (if (not (equal cc "")) (insert "Resent-cc: " cc "\n"))
  393.       (mh-clean-msg-header (point-min)
  394.                "^Message-Id:\\|^Received:\\|^Return-Path:\\|^Sender:\\|^Date:\\|^From:"
  395.                nil)
  396.       (save-buffer)
  397.       (message "Redistributing...")
  398.       (if mh-redist-full-contents
  399.       (call-process "/bin/sh" nil 0 nil "-c"
  400.             (format "mhdist=1 mhaltmsg=%s %s -push %s"
  401.                 buffer-file-name
  402.                 (expand-file-name mh-send-prog mh-progs)
  403.                 buffer-file-name))
  404.     (call-process "/bin/sh" nil 0 nil "-c"
  405.               (format "mhdist=1 mhaltmsg=%s mhannotate=1 %s -push %s"
  406.                   (mh-msg-filename msg folder)
  407.                   (expand-file-name mh-send-prog mh-progs)
  408.                   buffer-file-name)))
  409.       (mh-annotate-msg msg folder mh-note-dist
  410.                "-component" "Resent:"
  411.                "-text" (format "\"%s %s\"" to cc))
  412.       (kill-buffer draft)
  413.       (message "Redistributing...done"))))
  414.  
  415.  
  416. (defun mh-reply (message &optional includep)
  417.   "Reply to MESSAGE (default: current message).
  418. If optional prefix argument INCLUDEP provided, then include the message
  419. in the reply using filter mhl.reply in your MH directory.
  420. Prompts for type of addresses to reply to:
  421.    from    sender only,
  422.    to      sender and primary recipients,
  423.    cc/all  sender and all recipients.
  424. If the file named by `mh-repl-formfile' exists, it is used as a skeleton
  425. for the reply.  See also documentation for `\\[mh-send]' function."
  426.   (interactive (list (mh-get-msg-num t) current-prefix-arg))
  427.   (let ((minibuffer-help-form
  428.      "from => Sender only\nto => Sender and primary recipients\ncc or all => Sender and all recipients"))
  429.     (let ((reply-to (or mh-reply-default-reply-to
  430.             (completing-read "Reply to whom: "
  431.                      '(("from") ("to") ("cc") ("all"))
  432.                      nil
  433.                      t)))
  434.       (folder mh-current-folder)
  435.       (show-buffer mh-show-buffer)
  436.       (config (current-window-configuration)))
  437.       (message "Composing a reply...")
  438.       (mh-exec-cmd "repl" "-build" "-noquery" "-nodraftfolder"
  439.          (if (stringp mh-repl-formfile) ;must be string, but we're paranoid
  440.          (list "-form" mh-repl-formfile))
  441.          mh-current-folder message
  442.          (cond ((or (equal reply-to "from") (equal reply-to ""))
  443.             '("-nocc" "all"))
  444.            ((equal reply-to "to")
  445.             '("-cc" "to"))
  446.            ((or (equal reply-to "cc") (equal reply-to "all"))
  447.             '("-cc" "all" "-nocc" "me")))
  448.          (if includep
  449.          '("-filter" "mhl.reply")))
  450.       (let ((draft (mh-read-draft "reply"
  451.                   (expand-file-name "reply" mh-user-path)
  452.                   t)))
  453.     (delete-other-windows)
  454.     (save-buffer)
  455.     
  456.     (let ((to (mh-get-header-field "To:"))
  457.           (subject (mh-get-header-field "Subject:"))
  458.           (cc (mh-get-header-field "Cc:")))
  459.       (goto-char (point-min))
  460.       (mh-goto-header-end 1)
  461.       (or includep
  462.           (mh-in-show-buffer (show-buffer)
  463.         (mh-display-msg message folder)))
  464.       (mh-add-msgs-to-seq message 'answered t)
  465.       (message "Composing a reply...done")
  466.       (mh-compose-and-send-mail draft "" folder message to subject cc
  467.                     mh-note-repl "Replied:" config))))))
  468.  
  469.  
  470. (defun mh-send (to cc subject)
  471.   "Compose and send a letter.
  472. The file named by `mh-comp-formfile' will be used as the form.
  473. Do not call this function from outside mh-e; use \\[mh-smail] instead.
  474.  
  475. The letter is composed in mh-letter-mode; see its documentation for more
  476. details.  If `mh-compose-letter-function' is defined, it is called on the
  477. draft and passed three arguments: to, subject, and cc."
  478.   (interactive (list
  479.         (mh-read-address "To: ")
  480.         (mh-read-address "Cc: ")
  481.         (read-string "Subject: ")))
  482.   (let ((config (current-window-configuration)))
  483.     (delete-other-windows)
  484.     (mh-send-sub to cc subject config)))
  485.  
  486.  
  487. (defun mh-send-other-window (to cc subject)
  488.   "Compose and send a letter in another window.
  489. Do not call this function from outside mh-e;
  490. use \\[mh-smail-other-window] instead.
  491. See also documentation for `\\[mh-send]' function."
  492.   (interactive (list
  493.         (mh-read-address "To: ")
  494.         (mh-read-address "Cc: ")
  495.         (read-string "Subject: ")))
  496.   (let ((pop-up-windows t))
  497.     (mh-send-sub to cc subject (current-window-configuration))))
  498.  
  499.  
  500. (defun mh-send-sub (to cc subject config)
  501.   ;; Do the real work of composing and sending a letter.
  502.   ;; Expects the TO, CC, and SUBJECT fields as arguments.
  503.   ;; CONFIG is the window configuration before sending mail.
  504.   (let ((folder mh-current-folder)
  505.     (msg-num (mh-get-msg-num nil)))
  506.     (message "Composing a message...")
  507.     (let ((draft (mh-read-draft
  508.           "message"
  509.           (let (components)
  510.             (cond
  511.              ((file-exists-p
  512.                (setq components
  513.                  (expand-file-name mh-comp-formfile mh-user-path)))
  514.               components)
  515.              ((file-exists-p
  516.                (setq components
  517.                  (expand-file-name mh-comp-formfile mh-lib)))
  518.               components)
  519.              (t
  520.               (error (format "Can't find components file \"%s\""
  521.                      components)))))
  522.           nil)))
  523.       (mh-insert-fields "To:" to "Subject:" subject "Cc:" cc)
  524.       (goto-char (point-max))
  525.       (message "Composing a message...done")
  526.       (mh-compose-and-send-mail draft "" folder msg-num
  527.                 to subject cc
  528.                 nil nil config))))
  529.  
  530.  
  531. (defun mh-read-draft (use initial-contents delete-contents-file)
  532.   ;; Read draft file into a draft buffer and make that buffer the current one.
  533.   ;; USE is a message used for prompting about the intended use of the message.
  534.   ;; INITIAL-CONTENTS is filename that is read into an empty buffer, or NIL
  535.   ;; if buffer should not be modified.  Delete the initial-contents file if
  536.   ;; DELETE-CONTENTS-FILE flag is set.
  537.   ;; Returns the draft folder's name.
  538.   ;; If the draft folder facility is enabled in ~/.mh_profile, a new buffer is
  539.   ;; used each time and saved in the draft folder.  The draft file can then be
  540.   ;; reused.
  541.   (cond (mh-draft-folder
  542.      (let ((orig-default-dir default-directory)
  543.            (draft-file-name (mh-new-draft-name)))
  544.        (pop-to-buffer (generate-new-buffer
  545.                (format "draft-%s"
  546.                    (file-name-nondirectory draft-file-name))))
  547.        (condition-case ()
  548.            (insert-file-contents draft-file-name t)
  549.          (file-error))
  550.        (setq default-directory orig-default-dir)))
  551.     (t
  552.      (let ((draft-name (expand-file-name "draft" mh-user-path)))
  553.        (pop-to-buffer "draft")    ; Create if necessary
  554.        (if (buffer-modified-p)
  555.            (if (y-or-n-p "Draft has been modified; kill anyway? ")
  556.            (set-buffer-modified-p nil)
  557.            (error "Draft preserved")))
  558.        (setq buffer-file-name draft-name)
  559.        (clear-visited-file-modtime)
  560.        (unlock-buffer)
  561.        (cond ((and (file-exists-p draft-name)
  562.                (not (equal draft-name initial-contents)))
  563.           (insert-file-contents draft-name)
  564.           (delete-file draft-name))))))
  565.   (cond ((and initial-contents
  566.           (or (zerop (buffer-size))
  567.           (if (y-or-n-p
  568.             (format "A draft exists.  Use for %s? " use))
  569.               (if mh-error-if-no-draft
  570.               (error "A prior draft exists."))
  571.             t)))
  572.      (erase-buffer)
  573.      (insert-file-contents initial-contents)
  574.      (if delete-contents-file (delete-file initial-contents))))
  575.   (auto-save-mode 1)
  576.   (if mh-draft-folder
  577.       (save-buffer))            ; Do not reuse draft name
  578.   (buffer-name))
  579.  
  580.  
  581. (defun mh-new-draft-name ()
  582.   ;; Returns the pathname of folder for draft messages.
  583.   (save-excursion
  584.     (mh-exec-cmd-quiet t "mhpath" mh-draft-folder "new")
  585.     (buffer-substring (point-min) (1- (point-max)))))
  586.  
  587.  
  588. (defun mh-annotate-msg (msg buffer note &rest args)
  589.   ;; Mark the MESSAGE in BUFFER listing with the character NOTE and annotate
  590.   ;; the saved message with ARGS.
  591.   (apply 'mh-exec-cmd "anno" buffer msg args)
  592.   (save-excursion
  593.     (cond ((get-buffer buffer)        ; Buffer may be deleted
  594.        (set-buffer buffer)
  595.        (if (symbolp msg)
  596.            (mh-notate-seq msg note (1+ mh-cmd-note))
  597.            (mh-notate msg note (1+ mh-cmd-note)))))))
  598.  
  599.  
  600. (defun mh-insert-fields (&rest name-values)
  601.   ;; Insert the NAME-VALUE pairs in the current buffer.
  602.   ;; If field NAME exists, append VALUE to it.
  603.   ;; Do not insert any pairs whose value is the empty string.
  604.   (let ((case-fold-search t))
  605.     (while name-values
  606.       (let ((field-name (car name-values))
  607.         (value (car (cdr name-values))))
  608.     (cond ((equal value "")
  609.            nil)
  610.           ((mh-position-on-field field-name)
  611.            (insert " " value))
  612.           (t
  613.            (insert field-name " " value "\n")))
  614.     (setq name-values (cdr (cdr name-values)))))))
  615.  
  616.  
  617. (defun mh-position-on-field (field &optional ignore)
  618.   ;; Move to the end of the FIELD in the header.
  619.   ;; Move to end of entire header if FIELD not found.
  620.   ;; Returns non-nil iff FIELD was found.
  621.   ;; The optional second arg is for pre-version 4 compatibility.
  622.   (if (mh-goto-header-field field)
  623.       (progn
  624.     (mh-header-field-end)
  625.     t)))
  626.  
  627.  
  628. (defun mh-get-header-field (field)
  629.   ;; Find and return the body of FIELD in the mail header.
  630.   ;; Returns the empty string if the field is not in the header of the
  631.   ;; current buffer.
  632.   (if (mh-goto-header-field field)
  633.       (progn
  634.     (skip-chars-forward " \t")    ;strip leading white space in body
  635.     (let ((start (point)))
  636.       (mh-header-field-end)
  637.       (buffer-substring start (point))))
  638.     ""))
  639.  
  640. (fset 'mh-get-field 'mh-get-header-field) ;mh-e 4 compatibility
  641.  
  642. (defun mh-goto-header-field (field)
  643.   ;; Move to FIELD in the message header.
  644.   ;; Move to the end of the FIELD name, which should end in a colon.
  645.   ;; Returns T if found, NIL if not.
  646.   (goto-char (point-min))
  647.   (let ((case-fold-search t)
  648.     (headers-end (save-excursion
  649.               (mh-goto-header-end 0)
  650.               (point))))
  651.     (re-search-forward (format "^%s" field) headers-end t)))
  652.  
  653. (defun mh-header-field-end ()
  654.   ;; Move to the end of the current header field.
  655.   ;; Handles RFC 822 continuation lines.
  656.   (forward-line 1)
  657.   (while (looking-at "^[ \t]")
  658.     (forward-line 1))
  659.   (backward-char 1))        ;to end of previous line
  660.   
  661.  
  662. (defun mh-goto-header-end (arg)
  663.   ;; Find the end of the message header in the current buffer and position
  664.   ;; the cursor at the ARG'th newline after the header.
  665.   (if (re-search-forward "^-*$" nil nil)
  666.       (forward-line arg)))
  667.  
  668.  
  669. (defun mh-read-address (prompt)
  670.   ;; Read a To: or Cc: address, prompting in the minibuffer with PROMPT.
  671.   ;; May someday do completion on aliases.
  672.   (read-string prompt))
  673.  
  674.  
  675.  
  676. ;;; Mode for composing and sending a draft message.
  677.  
  678. (defvar mh-sent-from-folder nil)    ;Folder of msg assoc with this letter.
  679.  
  680. (defvar mh-sent-from-msg nil)        ;Number of msg assoc with this letter.
  681.  
  682. (defvar mh-send-args nil)        ;Extra args to pass to "send" command.
  683.  
  684. (defvar mh-annotate-char nil)        ;Character to use to annotate mh-sent-from-msg.
  685.  
  686. (defvar mh-annotate-field nil)        ;Field name for message annotation.
  687.  
  688. (put 'mh-letter-mode 'mode-class 'special)
  689.  
  690. ;;;###autoload
  691. (defun mh-letter-mode ()
  692.   "Mode for composing letters in mh-e.\\<mh-letter-mode-map>
  693. When you have finished composing, type \\[mh-send-letter] to send the message
  694. using the MH mail handling system.
  695. See the documentation for \\[mh-edit-mhn] for information on composing MIME
  696. messages.
  697.  
  698. \\{mh-letter-mode-map}
  699.  
  700. Variables controlling this mode (defaults in parentheses):
  701.  
  702.  mh-delete-yanked-msg-window (nil)
  703.     If non-nil, \\[mh-yank-cur-msg] will delete any windows displaying
  704.     the yanked message.
  705.  
  706.  mh-yank-from-start-of-msg (t)
  707.     If non-nil, \\[mh-yank-cur-msg] will include the entire message.
  708.     If `body', just yank the body (no header).
  709.     If nil, only the portion of the message following the point will be yanked.
  710.     If there is a region, this variable is ignored.
  711.  
  712.  mh-ins-buf-prefix (\"> \")
  713.     String to insert before each non-blank line of a message as it is
  714.     inserted in a draft letter.
  715.  
  716.  mh-signature-file-name (\"~/.signature\")
  717.     File to be inserted into message by \\[mh-insert-signature].
  718.  
  719. Upon invoking mh-letter-mode, text-mode-hook and mh-letter-mode-hook are
  720. invoked with no args, if those values are non-nil."
  721.  
  722.   (interactive)
  723.   (or mh-user-path (mh-find-path))
  724.   (make-local-variable 'paragraph-start)
  725.   (setq paragraph-start (concat "^[ \t]*[-_][-_][-_]+$\\|" paragraph-start))
  726.   (make-local-variable 'paragraph-separate)
  727.   (setq paragraph-separate
  728.     (concat "^[ \t]*[-_][-_][-_]+$\\|" paragraph-separate))
  729.   (make-local-variable 'mh-send-args)
  730.   (make-local-variable 'mh-annotate-char)
  731.   (make-local-variable 'mh-annotate-field)
  732.   (make-local-variable 'mh-previous-window-config)
  733.   (make-local-variable 'mh-sent-from-folder)
  734.   (make-local-variable 'mh-sent-from-msg)
  735.   (make-local-variable 'mail-header-separator)
  736.   (setq mail-header-separator "--------") ;for Hyperbole
  737.   (use-local-map mh-letter-mode-map)
  738.   (setq major-mode 'mh-letter-mode)
  739.   (mh-set-mode-name "MH-Letter")
  740.   (set-syntax-table mh-letter-mode-syntax-table)
  741.   (run-hooks 'text-mode-hook)
  742.   ;; if text-mode-hook turned on auto-fill, tune it for messages
  743.   (cond ((and (boundp 'auto-fill-hook) auto-fill-hook) ;emacs 18
  744.      (make-local-variable 'auto-fill-hook)
  745.      (setq auto-fill-hook 'mh-auto-fill-for-letter)))
  746.   (cond ((and (boundp 'auto-fill-function) auto-fill-function) ;emacs 19
  747.      (make-local-variable 'auto-fill-function)
  748.      (setq auto-fill-function 'mh-auto-fill-for-letter)))
  749.   (run-hooks 'mh-letter-mode-hook))
  750.  
  751.  
  752. (defun mh-auto-fill-for-letter ()
  753.   ;; Auto-fill in letters treats the header specially by inserting a tab
  754.   ;; before continuation line.
  755.   (if (mh-in-header-p)
  756.       (let ((fill-prefix "\t"))
  757.     (do-auto-fill))
  758.     (do-auto-fill)))
  759.  
  760.  
  761. (defun mh-in-header-p ()
  762.   ;; Return non-nil if the point is in the header of a draft message.
  763.   (save-excursion
  764.     (let ((cur-point (point)))
  765.       (goto-char (point-min))
  766.       (re-search-forward "^-*$" nil t)
  767.       (< cur-point (point)))))
  768.  
  769.  
  770. (defun mh-to-field ()
  771.   "Move point to the end of a specified header field.
  772. The field is indicated by the previous keystroke (the last keystroke
  773. of the command) according to the list in the variable mh-to-field-choices.
  774. Create the field if it does not exist.  Set the mark to point before moving."
  775.   (interactive)
  776.   (expand-abbrev)
  777.   (let ((target (cdr (or (assoc (char-to-string (logior last-input-char ?`))
  778.                 mh-to-field-choices)
  779.              ;; also look for a char for version 4 compat
  780.              (assoc (logior last-input-char ?`) mh-to-field-choices))))
  781.     (case-fold-search t))
  782.     (push-mark)
  783.     (cond ((mh-position-on-field target)
  784.        (let ((eol (point)))
  785.          (skip-chars-backward " \t")
  786.          (delete-region (point) eol))
  787.        (if (and (not (eq (logior last-input-char ?`) ?s))
  788.             (save-excursion
  789.               (backward-char 1)
  790.               (not (looking-at "[:,]"))))
  791.            (insert ", ")
  792.            (insert " ")))
  793.       (t
  794.        (if (mh-position-on-field "To:")
  795.            (forward-line 1))
  796.        (insert (format "%s \n" target))
  797.        (backward-char 1)))))
  798.  
  799.  
  800. (defun mh-to-fcc (&optional folder)
  801.   "Insert an Fcc: FOLDER field in the current message.
  802. Prompt for the field name with a completion list of the current folders."
  803.   (interactive)
  804.   (or folder
  805.       (setq folder (mh-prompt-for-folder
  806.             "Fcc"
  807.             (or (and mh-default-folder-for-message-function
  808.                  (save-excursion
  809.                    (goto-char (point-min))
  810.                    (funcall mh-default-folder-for-message-function)))
  811.             "")
  812.             t)))
  813.   (let ((last-input-char ?\C-f))
  814.     (expand-abbrev)
  815.     (save-excursion
  816.       (mh-to-field)
  817.       (insert (if (mh-folder-name-p folder)
  818.           (substring folder 1)
  819.         folder)))))
  820.  
  821.  
  822. (defun mh-insert-signature ()
  823.   "Insert the file named by mh-signature-file-name at the current point."
  824.   (interactive)
  825.   (insert-file-contents mh-signature-file-name)
  826.   (set-buffer-modified-p (buffer-modified-p))) ; force mode line update
  827.  
  828.  
  829. (defun mh-check-whom ()
  830.   "Verify recipients of the current letter, showing expansion of any aliases."
  831.   (interactive)
  832.   (let ((file-name buffer-file-name))
  833.     (save-buffer)
  834.     (message "Checking recipients...")
  835.     (mh-in-show-buffer ("*Recipients*")
  836.       (bury-buffer (current-buffer))
  837.       (erase-buffer)
  838.       (mh-exec-cmd-output "whom" t file-name))
  839.     (message "Checking recipients...done")))
  840.  
  841.  
  842.  
  843. ;;; Routines to compose and send a letter.
  844.  
  845. (defun mh-compose-and-send-mail (draft send-args
  846.                        sent-from-folder sent-from-msg
  847.                        to subject cc
  848.                        annotate-char annotate-field
  849.                        config)
  850.   ;; Edit and compose a draft message in buffer DRAFT and send or save it.
  851.   ;; SENT-FROM-FOLDER is buffer containing scan listing of current folder, or
  852.   ;; nil if none exists.
  853.   ;; SENT-FROM-MSG is the message number or sequence name or nil.
  854.   ;; SEND-ARGS is an optional argument passed to the send command.
  855.   ;; The TO, SUBJECT, and CC fields are passed to the
  856.   ;; mh-compose-letter-function.
  857.   ;; If ANNOTATE-CHAR is non-null, it is used to notate the scan listing of the
  858.   ;; message.  In that case, the ANNOTATE-FIELD is used to build a string
  859.   ;; for mh-annotate-msg.
  860.   ;; CONFIG is the window configuration to restore after sending the letter.
  861.   (pop-to-buffer draft)
  862.   (mh-letter-mode)
  863.   (setq mh-sent-from-folder sent-from-folder)
  864.   (setq mh-sent-from-msg sent-from-msg)
  865.   (setq mh-send-args send-args)
  866.   (setq mh-annotate-char annotate-char)
  867.   (setq mh-annotate-field annotate-field)
  868.   (setq mh-previous-window-config config)
  869.   (setq mode-line-buffer-identification (list "{%b}"))
  870.   (if (and (boundp 'mh-compose-letter-function)
  871.        mh-compose-letter-function)
  872.       ;; run-hooks will not pass arguments.
  873.       (let ((value mh-compose-letter-function))
  874.     (if (and (listp value) (not (eq (car value) 'lambda)))
  875.         (while value
  876.           (funcall (car value) to subject cc)
  877.           (setq value (cdr value)))
  878.         (funcall mh-compose-letter-function to subject cc)))))
  879.  
  880.  
  881. (defun mh-send-letter (&optional arg)
  882.   "Send the draft letter in the current buffer.
  883. If optional prefix argument is provided, monitor delivery.
  884. Run mh-before-send-letter-hook before doing anything."
  885.   (interactive "P")
  886.   (run-hooks 'mh-before-send-letter-hook)
  887.   (save-buffer)
  888.   (message "Sending...")
  889.   (let ((draft-buffer (current-buffer))
  890.     (file-name buffer-file-name)
  891.     (config mh-previous-window-config))
  892.     (cond (arg
  893.        (pop-to-buffer "MH mail delivery")
  894.        (erase-buffer)
  895.        (mh-exec-cmd-output mh-send-prog t "-watch" "-nopush"
  896.                    "-nodraftfolder" mh-send-args file-name)
  897.        (goto-char (point-max))    ; show the interesting part
  898.        (recenter -1)
  899.        (set-buffer draft-buffer))    ; for annotation below
  900.       (t
  901.        (mh-exec-cmd-daemon mh-send-prog "-nodraftfolder" "-noverbose"
  902.                    mh-send-args file-name)))
  903.     (if mh-annotate-char
  904.     (mh-annotate-msg mh-sent-from-msg
  905.              mh-sent-from-folder
  906.              mh-annotate-char
  907.              "-component" mh-annotate-field
  908.              "-text" (format "\"%s %s\""
  909.                      (mh-get-header-field "To:")
  910.                      (mh-get-header-field "Cc:"))))
  911.  
  912.     (cond ((or (not arg)
  913.            (y-or-n-p "Kill draft buffer? "))
  914.        (kill-buffer draft-buffer)
  915.        (if config
  916.            (set-window-configuration config))))
  917.     (if arg
  918.     (message "Sending...done")
  919.       (message "Sending...backgrounded"))))
  920.  
  921.  
  922. (defun mh-insert-letter (folder message verbatim)
  923.   "Insert a message into the current letter.
  924. Removes the message's headers using mh-invisible-headers.  Prefixes
  925. each non-blank line with mh-ins-buf-prefix.  Prompts for FOLDER and
  926. MESSAGE.  If prefix argument VERBATIM provided, do not indent and do
  927. not delete headers.  Leaves the mark before the letter and point after it."
  928.   (interactive
  929.    (list (mh-prompt-for-folder "Message from" mh-sent-from-folder nil)
  930.      (read-input (format "Message number%s: "
  931.                  (if mh-sent-from-msg
  932.                  (format " [%d]" mh-sent-from-msg)
  933.                    "")))
  934.      current-prefix-arg))
  935.   (save-restriction
  936.     (narrow-to-region (point) (point))
  937.     (let ((start (point-min)))
  938.       (if (equal message "") (setq message (int-to-string mh-sent-from-msg)))
  939.       (mh-exec-lib-cmd-output "mhl" "-nobell" "-noclear"
  940.                   (expand-file-name message
  941.                         (mh-expand-file-name folder)))
  942.       (cond ((not verbatim)
  943.          (mh-clean-msg-header start mh-invisible-headers mh-visible-headers)
  944.          (set-mark start)        ; since mh-clean-msg-header moves it
  945.          (mh-insert-prefix-string mh-ins-buf-prefix))))))
  946.  
  947.  
  948. (defun mh-yank-cur-msg ()
  949.   "Insert the current message into the draft buffer.
  950. Prefix each non-blank line in the message with the string in
  951. `mh-ins-buf-prefix'.  If a region is set in the message's buffer, then
  952. only the region will be inserted.  Otherwise, the entire message will
  953. be inserted if `mh-yank-from-start-of-msg' is non-nil.  If this variable
  954. is nil, the portion of the message following the point will be yanked.
  955. If `mh-delete-yanked-msg-window' is non-nil, any window displaying the
  956. yanked message will be deleted."
  957.   (interactive)
  958.   (if (and mh-sent-from-folder mh-sent-from-msg)
  959.       (let ((to-point (point))
  960.         (to-buffer (current-buffer)))
  961.     (set-buffer mh-sent-from-folder)
  962.     (if mh-delete-yanked-msg-window
  963.         (delete-windows-on mh-show-buffer))
  964.     (set-buffer mh-show-buffer)    ; Find displayed message
  965.     (let ((mh-ins-str (cond ((if (boundp 'mark-active)
  966.                      mark-active ;Emacs 19
  967.                    (mark)) ;Emacs 18
  968.                  (buffer-substring (region-beginning)
  969.                            (region-end)))
  970.                 ((eq 'body mh-yank-from-start-of-msg)
  971.                  (buffer-substring
  972.                   (save-excursion
  973.                     (goto-char (point-min))
  974.                     (mh-goto-header-end 1)
  975.                     (point))
  976.                   (point-max)))
  977.                 (mh-yank-from-start-of-msg
  978.                  (buffer-substring (point-min) (point-max)))
  979.                 (t
  980.                  (buffer-substring (point) (point-max))))))
  981.       (set-buffer to-buffer)
  982.       (save-restriction
  983.         (narrow-to-region to-point to-point)
  984.         (push-mark)
  985.         (insert mh-ins-str)
  986.         (mh-insert-prefix-string mh-ins-buf-prefix)
  987.         (insert "\n"))))
  988.     (error "There is no current message")))
  989.  
  990.  
  991. (defun mh-insert-prefix-string (mh-ins-string)
  992.   ;; Run mail-citation-hook to insert a prefix string before each line
  993.   ;; in the buffer.  Generality for supercite users.
  994.   (set-mark (point-max))
  995.   (goto-char (point-min))
  996.   (cond (mail-citation-hook
  997.      (run-hooks 'mail-citation-hook))
  998.     (mh-yank-hooks            ;old hook name
  999.      (run-hooks 'mh-yank-hooks))
  1000.     (t
  1001.      (or (bolp) (forward-line 1))
  1002.      (let ((zmacs-regions nil))    ;so "(mark)" works in XEmacs
  1003.        (while (< (point) (mark))
  1004.          (insert mh-ins-string)
  1005.          (forward-line 1))))))
  1006.  
  1007.  
  1008. (defun mh-fully-kill-draft ()
  1009.   "Kill the draft message file and the draft message buffer.
  1010. Use \\[kill-buffer] if you don't want to delete the draft message file."
  1011.   (interactive)
  1012.   (if (y-or-n-p "Kill draft message? ")
  1013.       (let ((config mh-previous-window-config))
  1014.     (if (file-exists-p buffer-file-name)
  1015.         (delete-file buffer-file-name))
  1016.     (set-buffer-modified-p nil)
  1017.     (kill-buffer (buffer-name))
  1018.     (message "")
  1019.     (if config
  1020.         (set-window-configuration config)))
  1021.     (error "Message not killed")))
  1022.  
  1023.  
  1024. ;;; Build the letter-mode keymap:
  1025.  
  1026. (define-key mh-letter-mode-map "\C-c\C-f\C-b" 'mh-to-field)
  1027. (define-key mh-letter-mode-map "\C-c\C-f\C-c" 'mh-to-field)
  1028. (define-key mh-letter-mode-map "\C-c\C-f\C-d" 'mh-to-field)
  1029. (define-key mh-letter-mode-map "\C-c\C-f\C-f" 'mh-to-fcc)
  1030. (define-key mh-letter-mode-map "\C-c\C-f\C-r" 'mh-to-field)
  1031. (define-key mh-letter-mode-map "\C-c\C-f\C-s" 'mh-to-field)
  1032. (define-key mh-letter-mode-map "\C-c\C-f\C-t" 'mh-to-field)
  1033. (define-key mh-letter-mode-map "\C-c\C-fb" 'mh-to-field)
  1034. (define-key mh-letter-mode-map "\C-c\C-fc" 'mh-to-field)
  1035. (define-key mh-letter-mode-map "\C-c\C-fd" 'mh-to-field)
  1036. (define-key mh-letter-mode-map "\C-c\C-ff" 'mh-to-fcc)
  1037. (define-key mh-letter-mode-map "\C-c\C-fr" 'mh-to-field)
  1038. (define-key mh-letter-mode-map "\C-c\C-fs" 'mh-to-field)
  1039. (define-key mh-letter-mode-map "\C-c\C-ft" 'mh-to-field)
  1040. (define-key mh-letter-mode-map "\C-c\C-i" 'mh-insert-letter)
  1041. (define-key mh-letter-mode-map "\C-c\C-q" 'mh-fully-kill-draft)
  1042. (define-key mh-letter-mode-map "\C-c\C-\\" 'mh-fully-kill-draft) ;if no C-q
  1043. (define-key mh-letter-mode-map "\C-c\C-s" 'mh-insert-signature)
  1044. (define-key mh-letter-mode-map "\C-c\C-^" 'mh-insert-signature) ;if no C-s
  1045. (define-key mh-letter-mode-map "\C-c\C-w" 'mh-check-whom)
  1046. (define-key mh-letter-mode-map "\C-c\C-y" 'mh-yank-cur-msg)
  1047. (define-key mh-letter-mode-map "\C-c\C-c" 'mh-send-letter)
  1048. (define-key mh-letter-mode-map "\C-c\C-m\C-f" 'mh-mhn-compose-forw)
  1049. (define-key mh-letter-mode-map "\C-c\C-m\C-e" 'mh-mhn-compose-anon-ftp)
  1050. (define-key mh-letter-mode-map "\C-c\C-m\C-t" 'mh-mhn-compose-external-compressed-tar)
  1051. (define-key mh-letter-mode-map "\C-c\C-m\C-i" 'mh-mhn-compose-insertion)
  1052. (define-key mh-letter-mode-map "\C-c\C-e" 'mh-edit-mhn)
  1053. (define-key mh-letter-mode-map "\C-c\C-m\C-u" 'mh-revert-mhn-edit)
  1054.  
  1055. ;; "C-c /" prefix is used in mh-letter-mode by pgp.el
  1056.  
  1057. ;;; autoloads from mh-mime
  1058.  
  1059. (autoload 'mh-mhn-compose-insertion "mh-mime"
  1060.   "Add a directive to insert a MIME message part from a file.
  1061. This is the typical way to insert non-text parts in a message.
  1062. See also \\[mh-edit-mhn]." t)
  1063.  
  1064. (autoload 'mh-mhn-compose-anon-ftp "mh-mime"
  1065.   "Add a directive for a MIME anonymous ftp external body part.
  1066. This directive tells MH to include a reference to a
  1067. message/external-body part retrievable by anonymous FTP.
  1068. See also \\[mh-edit-mhn]." t)
  1069.  
  1070. (autoload 'mh-mhn-compose-external-compressed-tar "mh-mime"
  1071.   "Add a directive to include a MIME reference to a compressed tar file.
  1072. The file should be available via anonymous ftp.  This directive
  1073. tells MH to include a reference to a message/external-body part.
  1074. See also \\[mh-edit-mhn]." t)
  1075.  
  1076. (autoload 'mh-mhn-compose-forw "mh-mime"
  1077.   "Add a forw directive to this message, to forward a message with MIME.
  1078. This directive tells MH to include another message in this one.
  1079. See also \\[mh-edit-mhn]." t)
  1080.  
  1081. (autoload 'mh-edit-mhn "mh-mime"
  1082.   "Format the current draft for MIME, expanding any mhn directives.
  1083. Process the current draft with the mhn program, which,
  1084. using directives already inserted in the draft, fills in
  1085. all the MIME components and header fields.
  1086. This step should be done last just before sending the message.
  1087. The mhn program is part of MH version 6.8 or later.
  1088. The `\\[mh-revert-mhn-edit]' command undoes this command.
  1089. For assistance with creating mhn directives to insert
  1090. various types of components in a message, see
  1091. \\[mh-mhn-compose-insertion] (generic insertion from a file),
  1092. \\[mh-mhn-compose-anon-ftp] (external reference to file via anonymous ftp),
  1093. \\[mh-mhn-compose-external-compressed-tar] \
  1094. \(reference to compressed tar file via anonymous ftp), and
  1095. \\[mh-mhn-compose-forw] (forward message)." t)
  1096.  
  1097. (autoload 'mh-revert-mhn-edit "mh-mime"
  1098.   "Undoes the effect of \\[mh-edit-mhn] by reverting to the backup file.
  1099. Optional non-nil argument means don't ask for confirmation." t)
  1100.